﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace UMO.UmoControls
{
    /// <summary>
    /// Interaction logic for UmoPanel.xaml
    /// </summary> 
    public partial class UmoPanel : UserControl
    {
        #region static fields
        
        
        #endregion

        #region private fields

        private Canvas ParentContainer;
        private bool IsHolded;
        private UserControl panelContent;
        public UserControl PanelContent
        {
            get
            {
                return this.panelContent;
            }
        }        

        #endregion

        #region CONSTRUCTORS

        public UmoPanel()
        {
            InitializeComponent();      
        }

        public UmoPanel(string panelName, UserControl contentElement, Thickness margins,
            HorizontalAlignment horizontalPref=HorizontalAlignment.Stretch, VerticalAlignment verticalPref=VerticalAlignment.Stretch,
            double width = 0, double height = 0,string caption="")
        {
            InitializeComponent();
            this.Name = panelName;
            this.PanelCaption.Content = caption;
            if (horizontalPref != HorizontalAlignment.Stretch)
            {
                this.HorizontalAlignment = horizontalPref;
            }
            if (verticalPref != VerticalAlignment.Stretch)
            {
                this.VerticalAlignment = verticalPref;
            }
            this.Margin = margins;
            if (width != 0)
            {
                this.Width = width;
            }
            if (height != 0)
            {
                this.Height = height;
            }
            //insert content
            if (contentElement != null)
            {
                this.PanelContainerGrid.Children.Add(contentElement);
                this.panelContent = contentElement;
            }
        }

        #endregion

        #region STATIC METHODS
        public static UserControl ReturnAlignedUserControl(UserControl input,string name, Thickness margins, 
            HorizontalAlignment horizontalPref = HorizontalAlignment.Stretch, VerticalAlignment verticalPref = VerticalAlignment.Stretch, 
            double width = 0, double height = 0)
        {
            input.Name = name;
            if (horizontalPref != HorizontalAlignment.Stretch)
            {
                input.HorizontalAlignment = horizontalPref;
            }
            if (verticalPref != VerticalAlignment.Stretch)
            {
                input.VerticalAlignment = verticalPref;
            }
            input.Margin = margins;
            if (width != 0)
            {
                input.Width = width;
            }
            if (height != 0)
            {
                input.Height = height;
            }
            return input;
        }
        #endregion
    }
}
